<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>解析对象</title>
</head>

<body>
    <!-- 
        把这个let url = `name = 张三 & age = 20 & 爱好 = 跑步`参数解析成对象
        结构为let obj = {name:'张三',age:20,hobby:'跑步'}
     -->
    <script>
        let url = `name = 张三 & age = 20 & hobby = 跑步`
        let arr = url.split('&')
        let obj = {}
        for (let i = 0; i < arr.length; i++) {
            let arr1 = arr[i].split('=')
            if(arr1[1]*1){
                arr1[1] = arr1[1]*1
            }
            obj[arr1[0]] = arr1[1]
        }
        console.log(obj);


    </script>
</body>

</html>